
function getnologintoken(){
	hui.ajax({
	    type : 'GET',
	    url : globleobj['domain']+'/residents/getnologintoken',
	    data : {},
	    beforeSend : function(){hui.loading();},
	    complete   : function(){hui.closeLoading();},
	    success : function(msg){
	    	var data = JSON.parse(msg)
	    	localStorage.setItem("noLoginToken",data.noLoginToken);	
	    	//alert(localStorage.getItem('noLoginToken'));  
	    },
	    error : function(e){
	        console.log(JSON.stringify(e));
	        hui.iconToast('读取消息失败', 'warn');
	    } 
	}); 
}
function gocommunityInfo(data){
	localStorage.setItem("communityInfo",JSON.stringify(data));
	hui.open('/html/community/communityInfo.html',{},true); 
}
function goimChat(){
	hui.open('/html/imChat.html',{},true);
	tokenSure('/html/imChat.html','login.html?name=myDoctore');
	tokenSure('/html/chatList.html','login.html?name=myDoctore');
}
//获取新闻类别
function getnewtypes(){
		hui.ajax({
		    type : 'POST',
		    url : globleobj['domain']+'/company/getnews',
		    data : {'token':token},
		    beforeSend : function(){hui.loading();},
		    complete   : function(){hui.closeLoading();},
		    success : function(msg){
//		    	console.log('getnewtypes:'+msg)
		    	var data = JSON.parse(msg)
		    	if(data.rc != 0){
		    		hui.toast(data.msg);
		    		return false; 
		    	}
		    	var options = ''; 
				for(var i= 0;i < 2; i++){
					options +=  '<li>'+
		                			'<a href="javascript:void(0)">'+
		                    			'<div class="hui-media-list-img">'+
					                    	'<img src="'+data.list[i].banner+'" />'+
					                    '</div>'+
					                    '<div class="hui-media-content">'+
					                        '<h1>'+(data.list[i].title).replace("<br/>","")+'</h1>'+
					                        '<div>'+data.list[i].content+'</div>'+
					                        '<span onclick="gocommunityInfo('+JSON.stringify(data.list[i]).replace(/"/g, "&quot;")+')">详情</span>'+
					                    '</div>'+
					                '</a>'+
				            	'</li>'
				}
				options += '<li onclick="goCommunityList()"><p  style="text-align: center;width: 100%;">---查看更多---</p></li>'
				hui(".hui-media-listUl").html(options)
				
		    	
		    },
		    error : function(e){
		        console.log(JSON.stringify(e));
		        hui.iconToast('读取消息失败', 'warn');
		    } 
		}); 
	}

function goCommunityList(){
	hui.open('/html/community.html',{},true);
}
hui.ready(function(){
	getnologintoken();
	getnewtypes();
	
	//轮播
	var swipe = new huiSwpie('#swipe');
	swipe.autoPlay = true;
	swipe.delay = 2000;
	swipe.run();
	
    
	//跳转社区
	hui('#nav-news').click(function(){
		hui.open('/html/community.html',{},true);
	});
	//跳转应用
	hui('#nav-forum').click(function(){
		hui.open('/html/application.html',{},true);
	});
	//跳转个人中心
	hui('#nav-my').click(function(){
		tokenSure('/html/personcenter.html','/html/login.html?name=personcenter')
	});
	hui('#myDoctore').click(function(){
		tokenSure('/html/locationCommunity/myDoctore.html','/html/login.html?name=myDoctore')
	})
});